package jp.co.iris_ltd.irisphotoeditor.util;

import jp.co.iris_ltd.irisphotoeditor.widget.CanvasImageView;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.MotionEvent;

public class TextArtTool extends ArtTool {
    private Bitmap mStampBitmap;
    private String mText;

    public TextArtTool(CanvasImageView targetCanpas) {

        init();
    }

    private void init() {
        mMode = ToolMode.Text;
        mPaint = new Paint();
        mPaint.setColor(Color.BLACK);
        mPaint.setTextAlign(Paint.Align.CENTER);
        mPaint.setAntiAlias(true);
        mText = "Sample Text";
    }

    @Override
    public void setPosition(MotionEvent event, float scale) {
        mX = event.getX() / scale;
        mY = (event.getY() - 60) / scale;
    }

    @Override
    public void drawCanvas(Canvas canvas) {
        canvas.drawText(mText, mX, mY, mPaint);
    }

    @Override
    public void restoreCanvas(Canvas canvas) {
        canvas.drawText(mText, mX, mY, mPaint);
    }

    @Override
    public void onDrawingFinish() {
        mStampBitmap.recycle();
    }

}
